﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {

            $('.btn-input').click(function () {

                if(${qo.parentId}>-1){
                    //点击添加或者编辑的时候,先清除模态框的缓存数据
                    $('#editForm input').val('');
                    //如果是data开头的,可以使用data方法来接收
                    var json = $(this).data("json");

                    //把目录的名称设置进去模态框
                    $('#parentName').val($('#${qo.parentId}').text());
                    //把parentId也设置进去
                    $('#parentIdd').val(${qo.parentId})
                    if (json) {
                        $('input[name=id]').val(json.id)
                        $('input[name=title]').val(json.title)
                        $('input[name=sequence]').val(json.sequence)

                    }
                    $('#myModal').modal('show');
                }else{
                    $.messager.alert("温馨提示","请先选择左边的字典明细后再进行添加!")
                }

            })

            $('.btn-submit').click(function () {
                //保存数据
                $('#editForm').ajaxSubmit(handlerMessage)
            })

            //删除操作
            $('.btn-delete').click(function () {
                //获取部门id
                var id = $(this).data('id');
                $.messager.confirm("警告", "是否确认删除?", function () {
                    $.get("/systemDictionaryItem/delete.do", {id: id}, handlerMessage);
                })
            })

        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="systemDictionaryItem"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典目录</h1>
        </section>
        <section class="content">
            <div class="box">
                <div class="row">
                    <div class="col-xs-3">
                        <div class="panel panel-success">
                            <div class="panel-heading">数据字典明细</div>
                            <div class="panel-body">
                                <div class="list-group">
                                    <#list systemDictionaries as sdts>
                                        <#--active-->
                                    <a id="${sdts.id}" href="/systemDictionaryItem/list.do?parentId=${sdts.id}"
                                       class="list-group-item ">${sdts.title}</a>
                                    </#list>
                                </div>
                            </div>
                        </div>
                        <script>
                            $('#${qo.parentId}').addClass("active");
                        </script>
                    </div>
                    <div class="col-xs-9">
                        <!--高级查询--->
                        <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list.do" method="post">
                            <input type="hidden" name="currentPage" id="currentPage" value="1">
                            <input type="hidden" name="parentId" id="parentId" value="${qo.parentId}">
                    <@shiro.hasPermission name="systemDictionaryItem:saveOrUpdate">
                    <a class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                    </@shiro.hasPermission>
                        </form>
                        <!--编写内容-->
                        <div class="box-body table-responsive no-padding ">
                            <table class="table table-hover table-bordered">
                                <tr>
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>序号</th>
                                    <th>操作</th>
                                </tr>
                        <#list result.list as systemDictionaryItem>
                            <tr>
                                <td>${systemDictionaryItem_index+1}</td>
                                <td>${systemDictionaryItem.title!}</td>
                                <td>${systemDictionaryItem.sequence!}</td>
                                <td>
                            <@shiro.hasPermission name="systemDictionaryItem:saveOrUpdate">
                                    <a href="#" class="btn btn-info btn-xs btn-input"
                                       data-json='${(systemDictionaryItem.json)!}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                            </@shiro.hasPermission>
                            <@shiro.hasPermission name="systemDictionaryItem:delete">
                                    <a href="#" class="btn btn-danger btn-xs btn-delete"
                                       data-id="${(systemDictionaryItem.id)!}">
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>
                            </@shiro.hasPermission>
                                </td>
                            </tr>
                        </#list>
                            </table>
                            <!--分页-->
                    <#include "../common/page.ftl">
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">字典明细新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" name="parentId" id="parentIdd">
                    <input type="hidden" name="id" id="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="parentName" class="col-sm-3 control-label">字典目录：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="parentName" name="parentName"
                                   placeholder="请输入字典目录" readonly>
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="title" class="col-sm-3 control-label">字典明细标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入字典明细标题">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sequence" class="col-sm-3 control-label">字典明细序号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence"
                                   placeholder="请输入字典明细序号">
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
